<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const users = [{username:'user1' , password:'password1'},{username:'user2',password:'password2'},{username:'user3',password:'password3'}];
    function authenticateUser(username,password){
        return new Promise((resolve,reject)=>{
            setTimeout(()=>{
                const user = users.find(user=>user.username===username && user.password===password);
                if(user){
                    resolve(user);
                }else{
                    reject('用户名或密码有误');
                }
            },2000);
        });
    };
    authenticateUser('user1','password1').then(()=>{
        console.log('Welcome,${user.username}!');
    },(error)=>{
        console.log(error.message);
    })
    </script>
</body>
</html>